import * as actionTypes from "./actionTypes";
import { fromJS  } from "immutable"; //把数据转为immutable对象，使用这个使用更要使用gget方法，使用set方法去变更state内容
const defaultState = fromJS({
  ulDate: [],
  textData: [],
  homeRightUlli: [],
});

// 导出一个纯函数
export default (state = defaultState, action) => {
  switch (action.type) {
    case actionTypes.getAllIndex:
      console.log("getAllIndex", action)
      return state.merge(
        {
          ulDate: fromJS(action.ulDate),
          textData: fromJS(action.textData),
          homeRightUlli: fromJS(action.homeRightUlli),
        }
      )
    // return state.set("ulDate", fromJS(action.ulDate)).set("textData", fromJS(action.textData)).set("homeRightUlli", fromJS(action.homeRightUlli));
    case actionTypes.setMoreList:
      console.log("setMoreList", action)
      return state.set("textData", state.get("textData").concat(fromJS(action.data)))
    default:
      return state;
  }

};
